package com.hs.jhzd.repository;

import java.util.List;

import com.hs.jhzd.entity.VideoPlay;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import com.hs.jhzd.entity.Content;

@Repository
public interface ContentRepository extends JpaRepository<Content, Long> {
  @Query("SELECT u from Content u where u.jsbh=:jsbh and u.type.subType = :subType order by id desc")
  List<Content> findByJsbhAndSubType(@Param("jsbh") String jsbh, @Param("subType") String subType);

  @Query("SELECT u from Content u where u.jsbh=:jsbh and u.type.id = :typeId order by id desc")
  List<Content> findByJsbhAndSubType(@Param("jsbh") String jsbh, @Param("typeId") Long typeId);

  @Query("SELECT u from Content u where u.jsbh=:jsbh and u.type.name = :typeName order by id desc")
  List<Content> findByJsbhAndType(@Param("jsbh") String jsbh, @Param("typeName") String typeName);

  @Query("SELECT u from Content u where u.jsbh=:jsbh and u.type.code = :typeCode order by id desc")
  List<Content> findByJsbhAndTypeCode(@Param("jsbh") String jsbh, @Param("typeCode") int typeCode);

  Page<Content> findByJsbhAndTypeOrderByIdDesc(String jsbh, String typeName, Pageable pageable);

  Page<Content> findByJsbhOrderByIdDesc(String jsbh, Pageable pageable);


  public Content findTop1ByJsbhOrderByCreateTimeDesc(String jsbh);


}
